﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ChoViet.CMS.ViewModels.BoxPromotionAdViewModel>" %>
<%@ Import Namespace="ChoViet.Lib.Common"%>
<%@ Import Namespace="ChoViet.Lib.Helpers" %>
<%@ Import Namespace="MyBase.MyWap"%>		
<script type="text/javascript">
    $(document).ready(function() {
        $("#featured").tabs({ fx: [{ opacity: "toggle", duration: 'slow' }, { opacity: "toggle", duration: 'normal'}],
            show: function(event, ui) {
                $('#featured .ui-tabs-panel .info').hide();
                var infoheight = $('.info', ui.panel).height();
                $('.info', ui.panel).css('height', '0px').animate({ 'height': infoheight }, 500);
            }
        }).tabs("rotate", 3000, true);
        $('#featured').hover(
			function() { $('#featured').tabs('rotate', 0, true); },
			function() { $('#featured').tabs('rotate', 5000, true); }
		);
        $('#featured .ui-tabs-panel a.hideshow').click(function() {
            if ($(this).text() == 'Hide') {
                $(this).parent('.info').animate({ 'height': '0px' }, 500);
                $(this).text('Show');
            }
            else {
                $(this).parent('.info').animate({ 'height': '70px' }, 500);
                $(this).text('Hide');
            }
            return false;
        });
    });
</script>

		<div id="featured" >
		<% if (Model.Ads.Count() > 0)
       {
           bool isSelected = true;
           string listContent ="";
           string listTitle = ""; 
           foreach (var item in Model.Ads)
           {
             %>
                <% string linkDetail = LinkUtils.domain + Html.AdDetailRoute(item);
               MyLoadTemplate mTemplate = new MyLoadTemplate();
               string[] arr = {item.ID.ToString(),item.Image,linkDetail,item.Title.Length > 100 ? item.Title.Substring(0,100)+"..." : item.Title, item.Content.Length > 250 ? item.Content.Substring(0,250) : item.Content}; 
               listContent = listContent + mTemplate.LoadTemplateByArray(Model.PathTemplateContent,arr);
               string[] arrtitle = { isSelected == true ? "ui-tabs-selected" : "", item.ID.ToString(), item.Title};
               listTitle = listTitle + mTemplate.LoadTemplateByArray(Model.PathTemplateTitle, arrtitle);
                isSelected = false;
           }%>
           <ul class="ui-tabs-nav">
           <%=listTitle.ToString()%>
	      </ul>
           <%=listContent.ToString()%>
        <%} %>

		</div>
